Ext.namespace('VAS');

VAS.ArticlePicGridPanel = Ext.extend(Ext.grid.GridPanel, {
	initComponent : function() {
		var _this=this;
		_this.cm  = new Ext.grid.ColumnModel(
			[
				new Ext.grid.RowNumberer(),
		        new Ext.grid.CheckboxSelectionModel({
					defaults : {
						sortable : true											
					}
				}),
		        {
			        header: '图名称',
			        dataIndex: 'ainame'
			    }
			    ,{
			        header: '图片',
			        dataIndex: 'aiurl',
			        renderer : _this.onEntryStatus.createDelegate(_this)
			    },
			    {
			        header: '图片描述',
			        dataIndex: 'aidesc'
			    }

		    ]
		);		
		_this.picLoadUrl = 'admin/article/ArticleAction!getPicGridDate.action';
		_this.ds = new Ext.data.Store({
			autoLoad : true,
			url : _this.picLoadUrl+'?id=' + this.content_id + '&gridPanelId='+this.gridPanelId+'&entryMenuId='+this.menuid,
			reader : new Ext.data.JsonReader({
				
			}, [
				{name: 'aiid'},
				{name: 'ainame'},
				{name: 'aiurl'},
				{name: 'aidesc'},
				{name: 'ordinal'},
				{name: 'arid'}
			])
		});	 
		
		_this.sm = new Ext.grid.CheckboxSelectionModel({
			defaults : {
				sortable : true											
			}
		});
		
		var config = {
			height : 400,
			viewConfig : {
				forceFit : true
			},
			store	:	_this.ds,
			cm		: 	_this.cm,
			enableColLock : false,
			loadMask : true,
			border : false,
			stripeRows : true,
			sm		: _this.sm

		};

		Ext.apply(this, config);
		Ext.apply(this.initialConfig, config);
		VAS.ArticlePicGridPanel.superclass.initComponent.apply(this, arguments);
	}
	
	,getView : function(){
        if(!this.view){
        	Ext.apply(this.viewConfig,{
            	sortAscText : '升序排列',
            	sortDescText : '降序排列',
            	columnsText : '列'
            });
            this.view = new Ext.grid.GridView(this.viewConfig);
        }
        return this.view;
    }
    ,onEntryStatus: function(value,p,record){
     
       var img="<img src='"+value+"' '>";  
            p.attr='ext:qtip="'+img+'" style="background-image:url('+value+') !important;  background-repeat: no-repeat;cursor: pointer;"';
      
	}
    
    
    
});
Ext.reg('articlePicGridPanel',VAS.ArticlePicGridPanel);


VAS.ArticlePicGridWin = Ext.extend(Ext.Window,{
	manager:wgroup,
	initComponent : function() {
	 	var _this=this;
	 	var thisConfig={
	 		width  : 600,
	 		items  : new VAS.ArticlePicGridPanel({content_id:this.content_id}),
	 		buttons : [{
            	xtype:'button',
            	text:'关闭',
            	handler : function() {
            		_this.close();	
            	}
	 		}]
	     };
		 Ext.apply(this, thisConfig);
		 Ext.apply(this.initialConfig, thisConfig);
		 VAS.ArticlePicGridWin.superclass.initComponent.apply(this);
	}
});


